<?php 

// No direct access
defined ('_JEXEC') or die();
JFormHelper::addFieldPath(JPATH_COMPONENT . '/models/fields');

$option = JRequest::getCmd('option');
$view = JRequest::getCmd('view');
$listOrder = $this->state->get('list.ordering');
$listDirn = $this->state->get('list.direction');
$status = JFormHelper::loadFieldType('status', false);
$statusOptions = $status->getOptions();

?>

<form action='index.php' method='post' name='adminForm' id='adminForm'>
	<input type="hidden" name="option" value="<?php echo $option; ?>" />
    <input type="hidden" name="task" value="" />
    <input type="hidden" name="view" value="<?php echo $view; ?>" />
    <input type="hidden" name="filter_order" value="<?php echo $listOrder; ?>" />
    <input type="hidden" name="filter_order_Dir" value="<?php echo $listDirn; ?>" />
    <input type='hidden' name='boxchecked' value='0'/>
    <?php 
    echo JHtml::_('form.token');
    echo JHTML::_('behavior.modal');
     ?>
    
    <fieldset id='filter-bar'>
		<div class='filter-search fltlft'>
    		<label for='filter_search'><?php echo JText::_('JSEARCH_FILTER_LABEL'); ?></label>
    		<input type='text' name='filter_search' id='filter_search' 
    			value='<?php echo $this->escape($this->state->get('filter.search')); ?>'
    			size="30"/>
			<select name='filter_status' class='inputbox' onchange='this.form.submit()'>
    			<option value=''><?php echo JText::_('JOPTION_SELECT_PUBLISHED');?></option>
    			<?php echo JHtml::_('select.options', $statusOptions, 'value', 'text', $this->state->get('filter.status'), true);?>
    		</select>
    		<button type='submit'><?php echo JText::_('JSEARCH_FILTER_SUBMIT'); ?></button>
    		<button type='button' onclick='document.id("filter_search").value="";this.form.submit();'>
    			<?php echo JText::_('JSEARCH_FILTER_CLEAR'); ?>
    		</button>
    	</div>
    </fieldset>
    
    <div class="clr"> </div>
    
	<div id='editcell'>
		<table class='adminlist'>
			<thead>
				<tr>
					<td><?php echo JHtml::_('grid.sort', 'ID', 'id', $listDirn, $listOrder)?></td>
					<td><?php echo JHtml::_('grid.sort', 'Status', 'status', $listDirn, $listOrder)?></td>
					<td><?php echo JHtml::_('grid.sort', 'Ngày đặt', 'orderdate', $listDirn, $listOrder); ?></td>
					<td><?php echo JHtml::_('grid.sort', 'Khách hàng', 'customer', $listDirn, $listOrder)?></td>
					<td><?php echo JHtml::_('grid.sort', 'Tên SP', 'productname', $listDirn, $listOrder)?></td>
					<td>Hình</td>
					<td>Số lượng</td>
					<td>Ngày về dự kiến</td>
				</tr>
			</thead>
			<tfoot>
				<tr>
					<td colspan='8' align="center">
						<?php echo $this->pagination->getListFooter(); ?>
					</td>
				</tr>
			</tfoot>
			<tbody>
			<?php
			$k = 0;
			$i = 0;
			foreach ($this->items as $row)
			{
				$checked = JHtml::_('grid.id', $i++, $row->id);
				$link = JRoute::_('index.php?option=' . $option . '&task=order.edit&id=' . $row->id);
			?>
				<tr class="row<?=$k?>">
					<td><?php echo $row->id; ?></td>
					<td><?php echo $row->status; ?></td>
					<td><?php echo $row->orderdate; ?></td>
					<td><?php echo $row->customer; ?></td>
					<td><?php echo $row->productname; ?></td>
					<td><img src="<?php echo $row->photo; ?>" style="width:100px; height:auto;"/></td>
					<td><?php echo $row->quantity; ?></td>
					<td><?php echo $row->vndate; ?></td>
				</tr>
			<?php
			$k = 1 - $k;
			}
			?>
			</tbody>
		</table>
	</div>
</form>